﻿using Unity.Environment;

namespace Unity.Kafka
{
    public class EnvironmentKafkaCredentials : UnityKafkaCredentials
    {
        public static readonly string EnvironmentParameterHost = "KAFKA_HOST";
        public static readonly string EnvironmentParameterTopic = "KAFKA_TOPIC";
        public static readonly string EnvironmentParameterClientId = "KAFKA_CLIENT_ID";
        public static readonly string EnvironmentParameterGroupId = "KAFKA_GROUP_ID";
        public static readonly string EnvironmentParameterTruststore = "KAFKA_TRUSTSTORE";
        public static readonly string EnvironmentParameterKeystoreCertificate = "KAFKA_KEYSTORE_CERT";
        public static readonly string EnvironmentParameterKeystoreKey = "KAFKA_KEYSTORE_KEY";
        public static readonly string EnvironmentParameterKeystorePassword = "KAFKA_KEYSTORE_PASS";

        public EnvironmentKafkaCredentials()
        {
            Servers = UnityEnvironment.GetStringParameter(EnvironmentParameterHost);
            Topic = UnityEnvironment.GetStringParameter(EnvironmentParameterTopic);
            GroupId = UnityEnvironment.GetStringParameter(EnvironmentParameterClientId);
            ClientId = UnityEnvironment.GetStringParameter(EnvironmentParameterGroupId);
            SslCertificationAuthority = UnityEnvironment.GetStringParameter(EnvironmentParameterTruststore);
            SslCert = UnityEnvironment.GetStringParameter(EnvironmentParameterKeystoreCertificate);
            SslKey = UnityEnvironment.GetStringParameter(EnvironmentParameterKeystoreKey);
            SslKeyPass = UnityEnvironment.GetStringParameter(EnvironmentParameterKeystorePassword);
        }
    }
}
